﻿using DigitalHealth.PACS.Model;
using DigitalHealth.PACS.UserService.Services;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace DigitalHealth.PACS.UserService.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class PACSUserController : ControllerBase
    {
        private IPACSUserServer PACSUserServer { get; set; }

        public PACSUserController(IPACSUserServer pACSUserServer)
        {
            this.PACSUserServer = pACSUserServer;
        }

        //获取所有用户
        [HttpGet]
        public IEnumerable<PACSUser> Get()
        {
            return PACSUserServer.GetUsers();
        }

        [HttpGet]
        [Route("{id}")]
        public PACSUser GetById(string id)
        {
            return PACSUserServer.GetUsersById(id);
        }
        
        [HttpPost]
        public void Post([FromBody] PACSUser user)
        {
            PACSUserServer.Update(user);
        }

        // PUT api/<ChatUserController>/5
        [HttpPut]
        public void Put([FromBody] PACSUser user)
        {
            PACSUserServer.Create(user);
        }

        // DELETE api/<ChatUserController>/5
        [HttpDelete]
        public void Delete([FromBody] PACSUser user)
        {
            PACSUserServer.Delete(user);
        }
    }
}
